﻿using System.Collections.Generic;
using UnityEngine;

public class Math
{
    public static List<Vector2Int> GetTargetPosition(Vector2Int currentPosition,List<Vector2Int> positions)
    {
        int x = currentPosition.x;
        int y = currentPosition.y;
        List<Vector2Int> targetPositions = new List<Vector2Int>();
        
        foreach (var position in positions)
        {
            if (position.x + x > 7 || position.y + y > 7 || position.x + x < 0 || position.y + y < 0)
                continue; 

            targetPositions.Add(new Vector2Int(position.x + x, position.y + y));
        }
        
        return targetPositions;
    }
    
    public static List<Vector2Int> GetEnemyTargetPosition(Vector2Int currentPosition,List<Vector2Int> positions)
    {
        int x = currentPosition.x;
        int y = currentPosition.y;
        List<Vector2Int> targetPositions = new List<Vector2Int>();
        
        foreach (var position in positions)
        {
            if (x - position.x > 7 || y - position.y > 7 || x - position.x < 0 || y - position.y < 0)
                continue; 

            targetPositions.Add(new Vector2Int(x - position.x, y - position.y));
        }
        
        return targetPositions;
    }
}
